//-----------------------------------AutumnalContainer.java-----------------------------------
import java.util.Properties;
import com.korustar.autumnal.codemodel.CodeModelBeanConstructionBuilder;
import com.korustar.autumnal.codemodel.CodeModelContainerBuilder;
import com.korustar.autumnal.codemodel.CodeModelContainerModel;
import com.korustar.autumnal.codemodel.CodeModelParameterBuilder;
import com.korustar.autumnal.codemodel.CodeModelSimpleOutputter;
import com.korustar.autumnal.codemodel.SpringContextAwareCodeModelSimpleRunner;


/**
 * Despringified Application Context
 * 
 * This code was generated from a Spring application context
 * 
 */
public class AutumnalContainer {

    /**
     * This object holds all your singleton beans, just like a Spring BeanFactory
     * 
     */
    private final AutumnalContainer.BeanHolder beanHolder = new AutumnalContainer.BeanHolder();

    /**
     * Start context. This is the entrypoint for starting the Application Context
     * 
     */
    public void startContainer()
        throws Exception
    {
        beanHolder.properties = new Properties();
        // org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0
        beanHolder.properties.load((new java.io.FileInputStream(new java.io.File( "spring/EatMyOwnDogFoodApplicationContext.properties"))));
        constructSingletons();
        setBeanProperties();
        afterPropertiesSet();
    }

    /**
     * Constructs all Singleton Beans and adds them to the beans map
     * 
     */
    private void constructSingletons()
        throws Exception
    {
        beanHolder.builder = new CodeModelContainerBuilder();
        beanHolder.constructionBuilder = new CodeModelBeanConstructionBuilder();
        beanHolder.parameterBuilder = new CodeModelParameterBuilder();
        beanHolder.runner = new SpringContextAwareCodeModelSimpleRunner();
        beanHolder.outputter = new CodeModelSimpleOutputter();
        beanHolder.model = new CodeModelContainerModel();
    }

    /**
     * Calls setters, and wires beans together as necessary
     * 
     */
    private void setBeanProperties() {
        // org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0
        // builder
        beanHolder.builder.setConstructionBuilder(beanHolder.constructionBuilder);
        beanHolder.builder.setDefineMainMethod(true);
        beanHolder.builder.setParameterBuilder(beanHolder.parameterBuilder);
        // constructionBuilder
        beanHolder.constructionBuilder.setParameterBuilder(beanHolder.parameterBuilder);
        // parameterBuilder
        // runner
        beanHolder.runner.setBuilder(beanHolder.builder);
        beanHolder.runner.setOutputter(beanHolder.outputter);
        // outputter
        beanHolder.outputter.setFolderName("spring");
        // model
        beanHolder.model.setContainerClassName("AutumnalContainer");
    }

    private void afterPropertiesSet()
        throws Exception
    {
        beanHolder.runner.run();
    }

    /**
     * Main method
     * 
     */
    public static void main(String[] args)
        throws Exception
    {
        new AutumnalContainer().startContainer();
    }

    private class BeanHolder {

        private Properties properties;
        private CodeModelContainerBuilder builder;
        private CodeModelBeanConstructionBuilder constructionBuilder;
        private CodeModelParameterBuilder parameterBuilder;
        private SpringContextAwareCodeModelSimpleRunner runner;
        private CodeModelSimpleOutputter outputter;
        private CodeModelContainerModel model;

    }

}
